﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace Interfaces
{
    public partial class BuscarManejoEconomico : System.Web.UI.Page
    {
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (Session["BuscarMaster"] != null)
            {
                string res = (string)Session["BuscarMaster"];
                this.MasterPageFile = res;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!User.Identity.IsAuthenticated)
                FormsAuthentication.RedirectToLoginPage();
         
            LabelError.Visible = false;
        }

        protected void RadioButton5_CheckedChanged(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (RadioButton4.Checked)
                {
                    DataList1.DataSource = Processes.GestorIngresoEgreso.getGestiones(DropDownList3.SelectedValue, null, null);
                }
                else
                {
                    DataList1.DataSource = Processes.GestorIngresoEgreso.getGestiones("0", TextBox1.Text, TextBox2.Text);
                }
                DataList1.DataBind();
            }
            catch (Exception ex)
            {
                LabelError.Visible = true;
                LabelError.Text = ex.Message;
            }
        }
   
        protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "Editar")
            {
                Label l = (Label)e.Item.FindControl("Gestion");
                Response.Redirect("ModificarIngresoEgreso.aspx?Gestion="+l.Text+"&Tipo=I");
            }
            else if (e.CommandName == "Grafica")
            {
                Label l = (Label)e.Item.FindControl("Gestion");
                Response.Redirect("GraficaAnual.aspx?Gestion=" + l.Text);
            }
            else
            {
                Label l = (Label)e.Item.FindControl("Gestion");
                Response.Redirect("VerGestion.aspx?Gestion=" + l.Text);
                
            }
        }

        protected void RadioButton4_CheckedChanged(object sender, EventArgs e)
        {
            Panel3.Visible = true;
            Panel4.Visible = false;
        }

        protected void RadioButton5_CheckedChanged1(object sender, EventArgs e)
        {
            Panel4.Visible = true;
            Panel3.Visible = false;
        
        }

        protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}